﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;

namespace System.Windows.Art
{
    public static class ColorSpaces
    {
        private static readonly Rgb rgb = Rgb.GetInstance();
        private static readonly XYZ xyz = XYZ.GetInstance();
        private static readonly Lab lab = Lab.GetInstance();
        private static readonly Hsv hsv = Hsv.GetInstance();
        private static readonly Hsl hsl = Hsl.GetInstance();

        public static Rgb Rgb { get { return ColorSpaces.rgb; } }
        public static XYZ XYZ { get { return ColorSpaces.xyz; } }
        public static Lab Lab { get { return ColorSpaces.lab; } }
        public static Hsv Hsv { get { return ColorSpaces.hsv; } }
        public static Hsl Hsl { get { return ColorSpaces.hsl; } }

        public static ColorSpaceBase[] GetAll()
        {
            return ColorSpaceBase.pool.ToArray();
        }

        public static T Translate<T>(IColor color, ColorSpace<T> other) where T : IColor
        {
            if (color.Space == other) return (T)color;
            else return other.FromColor(color.ToColor());
        }
    }
}
